﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PersistenceObject.Framework
{
    public class Combined<T1, T2>
        where T1 : class
        where T2 : class
    {
        private T1 _T1;

        public T1 TT1
        {
            get { return _T1; }
            set { _T1 = value; }
        }
        private T2 _T2;

        public T2 TT2
        {
            get { return _T2; }
            set { _T2 = value; }
        }

        public Combined(T1 t1, T2 t2)
        {
            this._T1 = t1;
            this._T2 = t2;
        }

        public T GetValue<T>() where T : class
        {
            String className = typeof(T).FullName;

            if (className == typeof(T1).FullName)
            {
                return _T1 as T;
            }

            return _T2 as T;
        }
                
        public void SetValue<T>(T t) where T : class
        {
            String className = typeof(T).FullName;

            if (className == typeof(T1).FullName)
            {
                this._T1 = t as T1;
            }

            this._T2 = t as T2;
        }

    }

    public class Combined<T1, T2,T3>
        where T1 : class
        where T2 : class
        where T3 : class
    {
        private T1 _T1;

        public T1 TT1
        {
            get { return _T1; }
            set { _T1 = value; }
        }
        private T2 _T2;

        public T2 TT2
        {
            get { return _T2; }
            set { _T2 = value; }
        }

        private T3 _T3;

        public T3 TT3
        {
            get { return _T3; }
            set { _T3 = value; }
        }

        public Combined(T1 t1, T2 t2,T3 t3)
        {
            this._T1 = t1;
            this._T2 = t2;
            this._T3 = t3;
        }

        public T GetValue<T>() where T : class
        {
            String className = typeof(T).FullName;


            if (className == typeof(T1).FullName)
            {
                return _T1 as T;
            }
            else if (className == typeof(T2).FullName)
            {
                return _T2 as T;
            }

            return _T3 as T;
        }

        public void SetValue<T>(T t) where T : class
        {
            String className = typeof(T).FullName;

            if (className == typeof(T1).FullName)
            {
                this._T1 = t as T1;
            }
            else if (className == typeof(T2).FullName)
            {
                this._T2 = t as T2; 
            }

            this._T3 = t as T3;
        }



    }

}
